<?php

  require("../configuracion.php");
  $idSysSection = $sectionAudiencia1;
  require("../application-top.php");

   require("registro-functions.php");
   require("registro-ctes.php");


   $n_row = $_GET['n_row'];
   $pag = $_GET['pag'];
   $order = $_GET['order'];
   $campo_order = $GET['campo_order'];
   $action = $_GET['action'];
   $buscar = $_GET['buscar'];



   if ($n_row == ""){
     $n_row = "10";
   }
   if ($pag == ""){
     $pag = 1;
   }
   if ($order == ""){
     $order = "ASC";
   }
   if ($campo_order == ""){
     $campo_order = "$cte_TiposRegistro_st_TipoRegistro";
   }

   if ($action == "buscar"){
     $total_registros = Total_Reg_Registroa($buscar);
     $n_paginas = ceil( $total_registros / $n_row);
     $query = Paginar_Registroa($pag,$n_row,$order,$total_registros,$campo_order,$buscar);
   }
   else if ($action == ""){
     $total_registros = Total_Reg_Registroa("");
     $n_paginas = ceil($total_registros / $n_row);
     $query = Paginar_Registroa(1,$n_row,$order,$total_registros,$campo_order,$buscar);
     $action = "paginar";
   }
   else if ($action=="paginar"){
     $total_registros = Total_Reg_Registroa("");
     $n_paginas = ceil($total_registros / $n_row);
     $query = Paginar_Registroa($pag,$n_row,$order,$total_registros,$campo_order,$buscar);
   }



   $liga = "";
   if ($action <> ""){
      $liga .= "&action=" . $action;
   }
   if ($buscar <> ""){
      $liga .= "&buscar=" . $buscar;
   }
   if ($n_row <> ""){
      $liga .= "&n_row=" . $n_row;
   }
?>

<html>
<head>
  <title><?= $instanciaECRM ?></title>
  <link rel="stylesheet" href="../styles/style.css" type="text/css">
</head>
<body leftmargin="0" class="mainBackground"  topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr><td><img src="../images/headerBar.gif" width="590" height="60" alt=""></td></tr>
  <tr>
    <td><table width="800" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#FFFFFF" valign="top" height="400">


<form>
<table border="0" cellpadding="5" cellspacing="0" width="750">
  <tr><td colspan="2"><table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr><td colspan="2"><img src="images/spacer.gif" height="10" width="1" alt=""></td></tr><tr><td><strong class="pageTitle"><?= $Audiencias1 ?></strong><br><strong class="pageSubtitle"><?= $cte_titulo4 ?></strong></td><td align="right"><a href="http://www.cacto.com/" target="_blank"><img src="../images/trademarkCacto.gif" alt="Cacto" border="0"></a><br>
<strong class="systemTitle"><?= $instanciaECRM ?></strong><br>Perfil <strong><?= $PerfilUsuario ?></strong></td></tr>
  </table></td></tr>
  <tr>
  <td valign="top">
    <table border="0" cellpadding="5" cellspacing="1" class="mainTableBG" width="250">
      <tr><td colspan="2" class="mainTableTitle"><strong>Informaci&oacute;n de <?= $Audiencias1 ?></strong></td></tr>
      <tr><td width="130" class="conceptCellBG"><a href="registro-admin.php"><?= $cte_titulo1 ?></a></td><td align="right" class="answerCellBG"><?= Total_Reg_Usuarios()  ?></td>
      <tr><td width="130" class="conceptCellBG"><a href="registro-admin1.php"><?= $cte_titulo2 ?></a></td><td align="right" class="answerCellBG"><?= Total_Reg_SMS("")  ?></td>
      <tr><td width="130" class="conceptCellBG"><a href="registro-admin2.php"><?= $cte_titulo3 ?></a></td><td align="right" class="answerCellBG"><?= Total_Reg_Contacto("")  ?></td>
      <tr><td width="130" class="conceptCellBG"><span class="titleBarTable"><?= $cte_titulo4 ?></span></td><td align="right" class="answerCellBG"><?= Total_Reg_Registroa("") ?></td></tr>
      <tr><td width="130" class="conceptCellBG"><a href="registro-admin4.php"><?= $cte_titulo5 ?></a></td><td align="right" class="answerCellBG"><?= Total_Reg_ContactoInbound("")  ?></td>
      <tr><td width="130" class="conceptCellBG"><a href="registro-admin5.php"><?= $cte_titulo6 ?></a></td><td align="right" class="answerCellBG"><?= Total_Reg_Mailing("")  ?></td>
      <tr><td width="130" class="conceptCellBG"><a href="registro-admin6.php"><?= $cte_titulo7 ?></a></td><td align="right" class="answerCellBG"><?= Total_Reg_Envia("")  ?></td>
      <tr><td width="130" class="conceptCellBG"><a href="registro-admin8.php"><?= $cte_titulo9 ?></a></td><td align="right" class="answerCellBG"><?= Total_Reg_Producto("")  ?></td>
      <tr><td width="130" class="conceptCellBG"><a href="registro-admin9.php"><?= $cte_titulo10 ?></a></td><td align="right" class="answerCellBG"><?= Total_Reg_ContactoOutbound("")  ?></td>
      <tr><td width="130" class="conceptCellBG"><a href="registro-admin10.php"><?= $cte_titulo11 ?></a></td><td align="right" class="answerCellBG"><?= Total_Reg_BajaPrograma("")  ?></td>
      <tr class="answerCellBG"><td colspan="2">Seleccione la tabla del sistema que desee consultar</td></tr>
    </table>
  </td>
  <td valign="top" width="100%">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr>
      <td align="right">

      <table border="0" cellpadding="2" cellspacing="0"  width="100%">
        <tr>
                  <td>
                     <?= RegistrosLista($pag,$n_row,$total_registros) ?>
                  </td>
                  <form method="GET" action="<?= $_SERVER['PHP_SELF'] ?>">
                  <td align="right">
                    <input type="text" name="buscar" value="<?= $buscar ?>">
                    <input type="hidden" name="action" value="buscar">
                    <input type="hidden" name="n_row" value="<?= $n_row ?>">
                  </td>
                  <td  width="5"><INPUT TYPE=IMAGE NAME="imagen" SRC="../images/icBuscar.gif"></td>
                  </form>
                 </tr>
      </table>
   
   
      </td>
      </tr>
      <tr><td><img src="../images/spacer.gif" height="5" width="1" alt=""></td></tr>
      <tr><td colspan="2">
        <table border="0" cellpadding="5" cellspacing="1" width="100%" class="secTableBG">
          <tr class="answerCellBG"><td colspan="3" align="right">
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
              <tr>
                               <form method="GET" action="<?= $_SERVER['PHP_SELF'] ?>">
                <td>Mostrar
                                  <select name="n_row">
<?
                                $registros[0] = "10";
                                $registros[1] = "25";
                                $registros[2] = "50";
                                $registros[3] = "100";
                                foreach($registros as $n){
                                  if ($n == $n_row){
                                    print "<option value=\"" . $n . "\" selected>" . $n . "</option>\n";
                                  }
                                  else {
                                    print "<option value=\"" . $n . "\">" . $n . "</option>\n";
                                  }
                                }
?>
                                  </select>
                                 <input type="hidden" name="action" value="<?= $action ?>">
                                 <input type="hidden" name="buscar" value="<?= $buscar ?>">
                                 <INPUT TYPE=IMAGE NAME="imagen" SRC="../images/icArrowGo.gif">
                                </td>
                                 </form>
</td>
                <td align="right">
<?php
      $_liga1 = "";

      if ($n_row <> "") $_liga1 .= "&n_row=" . $n_row;
      if ($action <> "") $_liga1 .= "&action=" . $action;
      if ($buscar <> "") $_liga1 .= "&buscar=" . $buscar;
      if ($order <> "") $_liga1 .= "&order=" . $order;
      if ($id_TipoRegistro <> "") $_liga1 .= "&id_TipoRegistro=" . $id_TipoRegistro;


    paginar($pag,$n_paginas,$_liga1);
?>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td width="80%" class="secTableBG">
          <table border="0" cellpadding="2" cellspacing="0">
            <tr>
              <td width="100%"  class="secTableTitle"><strong>Tipo de Registro</strong></td>
              <td><a href="<?= $_SERVER['PHP_SELF'] ?>?order=asc&campo_order=<?= $cte_TiposRegistro_st_TipoRegistro ?><?= $liga ?>"><img src="../images/icSortAsc.gif" height="12" width="13" alt="Orden Ascendente" border="0"></a></td>
              <td><a href="<?= $_SERVER['PHP_SELF'] ?>?order=desc&campo_order=<?= $cte_TiposRegistro_st_TipoRegistro ?><?= $liga ?>"><img src="../images/icSortDesc.gif" height="12" width="13" alt="Orden Descendente" border="0"></a></td>
            </tr>
          </table>
        </td>
      </tr>
     
<?
    $result = mssql_query ($query);
    $_class="conceptCellBG";
    while ($row = mssql_fetch_object($result)):
?>
              <tr class="<?= $_class ?>">
                    <td><a href="registro-consul3.php?id_TipoRegistro=<?= $row->$cte_id_TipoRegistro ?>" target="content"><?= $row->$cte_TiposRegistro_st_TipoRegistro ?></a></td>
                    </tr>


<?
      if ($_class == "conceptCellBG"){
         $_class = "answerCellBG";
      }
      else {
         $_class="conceptCellBG";
      }
    endwhile ?>

          <tr class="answerCellBG"><td colspan="3" align="right">
<?
     paginar($pag,$n_paginas,$_liga1);
?>
     </td></tr>
        </table>
      </td></tr>
    </table>
  
  
  
  </td>
  </tr>
</table>
          </td>
          <td width="36">&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
</form>
<br>
<br>
<br>
<table width="750" border="0" cellpadding="5" cellspacing="0">
  <tr>
    <td align="right"><span class="copyright"><?= $copyright ?></span></td>
  </tr>
</table>
</body>
</html>
